import sys
import os
from PySide6.QtWidgets import *
from PySide6.QtGui import *
from PySide6.QtCore import *

class Demo(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.parent = parent
        mainLayout = QVBoxLayout()
        groupBox = QGroupBox('Default GroupBox')        
        groupBoxLayout = QVBoxLayout()        

        cb = QCheckBox('CheckBox1',self,objectName='CheckBox1')
        groupBoxLayout.addWidget(cb)        

        cb = QCheckBox('CheckBox2',self,objectName='CheckBox2') 
        groupBoxLayout.addWidget(cb)        

        cb = QCheckBox('CheckBox3',self,objectName='CheckBox3')
        groupBoxLayout.addWidget(cb)
        groupBox.setLayout(groupBoxLayout)

        mainLayout.addWidget(groupBox)

        groupBox1 = QGroupBox()
        groupBox1.toggled.connect(self.groupToggled)
        groupBox1.setTitle('Checkable GroupBox')
        groupBox1.setCheckable(True)
        groupBox1.setChecked(True)  
        groupBox1.setAlignment(Qt.AlignmentFlag.AlignTop)      
        groupBox1.clicked.connect(self.groupClicked)        
        groupBoxLayout1 = QVBoxLayout()        

        cb = QCheckBox('CheckBox4',self,objectName='CheckBox1')
        groupBoxLayout1.addWidget(cb)        

        cb = QCheckBox('CheckBox5',self,objectName='CheckBox2') 
        groupBoxLayout1.addWidget(cb)        

        cb = QCheckBox('CheckBox6',self,objectName='CheckBox3')
        groupBoxLayout1.addWidget(cb)
        groupBox1.setLayout(groupBoxLayout1)

        mainLayout.addWidget(groupBox1)

        self.setLayout(mainLayout) 
    def groupClicked(self,checked):
        self.parent.OnShowMessage(f'GroupBox clicked,checked={checked}')
    def groupToggled(self,checked):
        self.parent.OnShowMessage(f'GroupBox toggled,checked={checked}')

def runDemo(parent):
    wigdet =  Demo(parent)
    return wigdet